﻿namespace Pub.Class
{
    using System;

    public abstract class Singleton2<T> where T: new()
    {
        private Singleton2()
        {
        }

        public static T Instance()
        {
            return Singleton2Creator.instance;
        }

        private class Singleton2Creator
        {
            internal static readonly T instance;

            static Singleton2Creator()
            {
                Singleton2<T>.Singleton2Creator.instance = (default(T) == null) ? Activator.CreateInstance<T>() : default(T);
            }
        }
    }
}

